Skip to content

feat: JSON Schema support + generator drift detection (LED-713)#2

Merged
infracore merged 5 commits intomainfrom
feat/json-schema-support
Apr 7, 2026
Merged

feat: JSON Schema support + generator drift detection (LED-713)#2
infracore merged 5 commits intomainfrom
feat/json-schema-support

Conversation

@infracore
Copy link
Copy Markdown
Member

Summary

  • Adds first-class JSON Schema support to delimit-action via new core/json_schema_diff.py sibling module
  • Adds generator drift detection (core/generator_drift.py) for catching staleness between source-of-truth (Zod, protobuf, etc.) and committed generated artifacts
  • Adds fail_on_breaking, generator_command, generator_artifact action inputs
  • Adds JSON Schema branch to PR comment renderer

Why

Validating delimit-action against agents-oss/agentspec#21 (maintainer invited integration) revealed the diff engine returned 0 changes on bare JSON Schema files. This release closes the gap before the agentspec PR opens.

Test plan

  • 41 new unit tests in tests/test_json_schema_diff.py — all passing
  • 47 existing OpenAPI tests still passing (no regressions) — 88 total
  • End-to-end verified against the real agentspec checkout running pnpm run schema:export
  • Generator drift detection tested on a stale-artifact scenario, restores workspace cleanly
  • Dispatcher correctly routes JSON Schema → JSONSchemaDiffEngine, OpenAPI → OpenAPIDiffEngine, ambiguous → OpenAPI (back-compat)

Scope (v1)

Property add/remove, required add/remove, type widen/narrow, enum add/remove, const, additionalProperties, pattern, minLength/maxLength, minimum/maximum, items type. $ref to #/definitions resolved at root and nested. Composition keywords (anyOf/oneOf/allOf), discriminators, external $ref, and if/then/else deferred past v1.

🤖 Generated with Claude Code

infracore and others added 5 commits March 30, 2026 21:35
Guards against None schemas in _compare_schema_deep, found during
Directus (34K stars) showcase run. Also adds null guards at top
of diff() method.

128 tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds first-class JSON Schema support to delimit-action so it can run
governance checks against schema files like agents-oss/agentspec's
agent.schema.json (issue #21).

Changes:

- core/json_schema_diff.py — new sibling module to diff_engine_v2.
  Handles Draft 4+ single-file schemas with internal $ref resolution
  to #/definitions. Covers 12 v1 change types: property add/remove,
  required add/remove, type widen/narrow, enum add/remove, const,
  additionalProperties, pattern, minLength/maxLength,
  minimum/maximum, items type. Composition keywords (anyOf/oneOf/
  allOf) and external $ref deferred past v1.

- core/generator_drift.py — new module that runs a regen command in
  a sandbox and diffs the regenerated artifact against the committed
  version. Catches drift between source-of-truth (e.g. Zod) and
  committed generated artifacts. Restores the workspace cleanly so
  the working tree is unmodified after the check.

- core/spec_detector.py — added detect_spec_type() classifier and
  get_diff_engine() factory. Routes JSON Schema files to the new
  engine; OpenAPI files keep the existing path. Back-compat: ambiguous
  docs default to OpenAPI.

- action.yml — three new inputs:
  - fail_on_breaking (boolean alias for mode=enforce)
  - generator_command (opt-in drift check)
  - generator_artifact (paired with generator_command)
  Plus dispatch logic in the validate step and a new JSON Schema
  branch in the Comment-on-PR step that renders drift + classification.

- tests/test_json_schema_diff.py — 41 unit tests covering every v1
  change type, $ref resolution at root and nested paths, dispatcher
  routing, and the agentspec rename as a real-world fixture.

Test results:
- 41/41 new JSON Schema tests pass
- 47/47 existing OpenAPI diff_engine tests still pass (no regressions)

Verified end-to-end against the agents-oss/agentspec checkout with
the real pnpm run schema:export generator. All three scenarios
(clean main, simulated rename PR, hypothetical version bump) classify
correctly with expected output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous header rendered "0 change(s), 1 breaking" when the
committed schema was unchanged but generator drift was detected.
Suppress the schema-classification line entirely when the diff is
empty, and surface drift as a separate "Generator drift: N change(s),
N breaking" line so the two signals never appear comma-joined.

Caught by deliberation on the live infracore/agentspec#1 test run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@crypttrx crypttrx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving per consensus deliberation + founder approval in chat. 88/88 unit tests passing. Smoke test failures are pre-existing and unrelated.

@infracore infracore merged commit 0ae02e8 into main Apr 7, 2026
4 of 6 checks passed
@infracore infracore deleted the feat/json-schema-support branch April 7, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants